import React, {
    Component,
} from 'react';
import {
    StyleSheet,
    Text,
    View,
    Platform,
    Dimensions,
    TouchableOpacity,
    Image,
    Alert,
    FlatList,
    TextInput,
    Linking,
    ScrollView,
    Switch,
    DeviceEventEmitter,
} from 'react-native';
import { conditionObjWithType } from '../../../utils/Conditions'
import Constant from '../../../utils/Constant'


let navigation

const isIos = Platform.OS == 'ios';

export default class CarRecordPage extends Component {

    constructor(props) {
        super(props);
        let data = this.props.route && this.props.route.params && this.props.route.params.data ? this.props.route.params.data : {}
        this.state = {
            data
        }
    }

    componentDidMount() {

    }

    render() {
        navigation = this.props.navigation;
        return (
            <View style={styles.container}>
                <Header navigation={navigation} Title={'车辆档案'} ></Header>
                <ScrollView
                    style={{ flex: 1 }}
                >
                    <View style={[styles.itemBox, {marginTop: 10}]}>
                        <Text style={styles.itemTitleText}>库存号</Text>
                        <Text style={styles.itemDesText}>{this.state.data.carId}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>车架号</Text>
                        <Text style={styles.itemDesText}>{this.state.data.vcode ? this.state.data.vcode:'-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>车辆类型</Text>
                        <Text style={styles.itemDesText}>{this.state.data.carType == 1 ? '新车':'二手车'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>品牌车型</Text>
                        <Text style={styles.itemDesText}>{this.state.data.seriesName+' '+this.state.data.speciesName+this.state.data.speciesName}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>表显里程</Text>
                        <Text style={styles.itemDesText}>{this.state.data.mileage ? (this.state.data.mileage / 10000).toFixed(2) + '万公里' : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>排量</Text>
                        <Text style={styles.itemDesText}>{this.state.data.displacement ? (this.state.data.displacement).toFixed(1) +(this.state.data.turbo ? 'T':'L') : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>上牌日期</Text>
                        <Text style={styles.itemDesText}>{this.state.data.registerDate}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>外观颜色</Text>
                        <Text style={styles.itemDesText}>{this.state.data.color && this.state.data.color.length > 0 ? this.state.data.color[0].outerColor:'-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>内部车辆编号</Text>
                        <Text style={styles.itemDesText}>{this.state.data.innerNo ? this.state.data.innerNo:'-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>库存状态</Text>
                        <Text style={styles.itemDesText}>{conditionObjWithType('storeStatus')[this.state.data.storeStatus]}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>上架时间</Text>
                        <Text style={styles.itemDesText}>{this.state.data.upperTime}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>钥匙数量</Text>
                        <Text style={styles.itemDesText}>{this.state.data.keyNum !== '' && this.state.data.keyNum !== undefined ? this.state.data.keyNum+'把':'-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>过户次数</Text>
                        <Text style={styles.itemDesText}>{this.state.data.transferTimes !== '' && this.state.data.transferTimes != undefined ? this.state.data.transferTimes+'次':'-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>使用性质</Text>
                        <Text style={styles.itemDesText}>{this.state.data.useNature ? conditionObjWithType('useNature')[this.state.data.useNature] : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>车牌号</Text>
                        <Text style={styles.itemDesText}>{this.state.data.plateNumber ? this.state.data.plateNumber : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>所有权归属</Text>
                        <Text style={styles.itemDesText}>{this.state.data.ownershipEntity ? conditionObjWithType('ownershipEntity')[this.state.data.ownershipEntity] : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>发动机号</Text>
                        <Text style={styles.itemDesText}>{this.state.data.ecode ? this.state.data.ecode : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>出厂日期</Text>
                        <Text style={styles.itemDesText}>{this.state.data.productionDate ? this.state.data.productionDate : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>内饰颜色</Text>
                        <Text style={styles.itemDesText}>{this.state.data.color && this.state.data.color.length > 0 && this.state.data.color[0].innerColor ? this.state.data.color[0].innerColor : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>变速箱</Text>
                        <Text style={styles.itemDesText}>{this.state.data.gearboxType ? conditionObjWithType('gearboxType')[this.state.data.gearboxType] : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>排放标准</Text>
                        <Text style={styles.itemDesText}>{this.state.data.emissionStd ? conditionObjWithType('emissionStd')[this.state.data.emissionStd] : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>燃油类型</Text>
                        <Text style={styles.itemDesText}>{this.state.data.energyType ? conditionObjWithType('energyType')[this.state.data.energyType] : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>车型级别</Text>
                        <Text style={styles.itemDesText}>{this.state.data.carRank ? conditionObjWithType('carRank')[this.state.data.carRank] : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>车身结构</Text>
                        <Text style={styles.itemDesText}>{this.state.data.bodyStyle ? conditionObjWithType('bodyStyle')[this.state.data.bodyStyle] : '-'}</Text>
                    </View>
                    <View style={styles.itemBox}>
                        <Text style={styles.itemTitleText}>所在地</Text>
                        <Text style={styles.itemDesText}>{this.state.data.merchantCity ? this.state.data.merchantCity : '-'}</Text>
                    </View>

                    <View style={{height: Constant.bottomHeight}}/>

                </ScrollView>
            </View>
        )
    }

}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#F9F9F9',
    },
    itemBox: {
        backgroundColor: '#fff',
        width: '100%',
        paddingHorizontal: 16,
        height: 44,
        flexDirection: 'row',
        justifyContent: 'flex-start',
        alignItems: 'center'
    },
    itemTitleText: {
        color: '#999',
        fontSize: 14,
        width: 96,
    },
    itemDesText: {
        color: '#333333',
        fontSize: 14,
        flex: 1,
    }

})